package cn.zqh.commodity;

import cn.zqh.commodity.client.BrandClient;
import cn.zqh.commodity.client.StoreClient;
import cn.zqh.commodity.config.DefaultFeignConfiguration;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import feign.Request;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: zqh
 * @Date: 2022-12-24-13:19
 * @Description: 商品启动类$
 */
@SpringBootApplication
@MapperScan("cn.zqh.commodity.mapper")
@EnableDiscoveryClient
@EnableTransactionManagement
@EnableFeignClients(clients = { BrandClient.class, StoreClient.class}, defaultConfiguration = {DefaultFeignConfiguration.class})
public class CommodityApplication {
    public static void main(String[] args) {
        SpringApplication.run(CommodityApplication.class, args);

    }

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }


    /**
      * @Author: zqh
      * @Date: 
      * @Description: 远程调用轮询
    */
    @Bean
    public IRule randomRule(){
        return new RandomRule();
    }

    @Bean
    public Request.Options feignOptions() {
        return new Request.Options(6000, 6000);
    }
}
